home *** CD-ROM | disk | FTP | other *** search
/ Belgian Amiga Club - ADF Collection / BS1 part 43.zip / Sources C- WorkDisk V.adf / scroll.c < prev    next >
C/C++ Source or Header  |  1987-02-15  |  3KB  |  130 lines

  1. #include "exec/types.h"
  2. #include "intuition/intuition.h"
  3.  
  4. struct IntuitionBase *IntuitionBase;
  5. struct GfxBase *GfxBase;
  6.  
  7. struct Screen *Scrn;
  8. struct Window *NoBorder;
  9. struct RastPort *rp;
  10. struct ViewPort *vp;
  11.  
  12. #define WIDTH  320*3
  13. #define HEIGHT 200
  14.  
  15. #define MODBLU 0x10
  16. #define MODRED 0x20
  17. #define MODGRN 0x30
  18.  
  19. struct NewScreen NewScrn =
  20. {
  21.  0,0,
  22.  WIDTH,HEIGHT,6,
  23.  1,0,
  24.  HAM,
  25.  CUSTOMSCREEN,
  26.  NULL,                    /* Pointer to custom font */
  27.  NULL,                    /* Pointer to title text */
  28.  NULL,                    /* Pointer to screen gadgets */
  29.  NULL                     /* Pointer to custom bitmap */
  30. };
  31.  
  32. struct NewWindow NewNoBorder =
  33. {
  34.  0,0,
  35.  WIDTH,HEIGHT,
  36.  0,0,
  37.  CLOSEWINDOW,             /*  IDCMP flags */
  38.  SMART_REFRESH | ACTIVATE | BORDERLESS | WINDOWCLOSE, /* flags */
  39.  NULL,                    /* Pointer to first gadget */
  40.  NULL,                    /* Pointer to Check Mark image */
  41.  NULL,                    /* Title */
  42.  NULL,                    /* Pointer to Screen structure */
  43.  NULL,                    /* Pointer to custom bitmap */
  44.  0,0,                     /* Min Width, Min Height */
  45.  0,0,                     /* Max Width, Max Height */     
  46.  CUSTOMSCREEN             /* Type of Screen this window resides on */
  47. };
  48.  
  49. main()
  50. {
  51.  
  52. OpenALL();
  53.  
  54. if((NewNoBorder.Screen = Scrn = (struct Screen *)OpenScreen(&NewScrn)) == NULL)
  55.  CloseALL();
  56.  
  57. if((NoBorder = (struct Window *)OpenWindow(&NewNoBorder)) == NULL)
  58.  CloseALL();
  59.  
  60. vp = (struct ViewPort *) ViewPortAddress(NoBorder);
  61. rp = NoBorder->RPort;
  62.  
  63. SetRGB4(vp,0,0,0,0);
  64. SetRGB4(vp,1,15,0,0);
  65. SetRGB4(vp,2,0,0,15);
  66. SetRGB4(vp,3,0,15,0);
  67.  
  68. drawham();
  69. scroll();
  70.  
  71. Wait(1 << NoBorder->UserPort->mp_SigBit);
  72.  
  73. CloseALL();
  74. }
  75.  
  76. OpenALL()
  77. {
  78.  if((IntuitionBase = (struct IntuitionBase *)
  79.      OpenLibrary("intuition.library",0)) == NULL) CloseALL();
  80.  
  81.  if((GfxBase = (struct GfxBase *)
  82.      OpenLibrary("graphics.library",0)) == NULL) CloseALL();
  83. }
  84.  
  85. CloseALL()
  86. {
  87.  if(NoBorder) CloseWindow(NoBorder);
  88.  if(Scrn) CloseScreen(Scrn);
  89.  if(GfxBase) CloseLibrary(GfxBase);
  90.  if(IntuitionBase) CloseLibrary(IntuitionBase);
  91.  exit(1);
  92. }
  93.  
  94. drawham()
  95. {
  96.  int c;
  97.  
  98.  for(c=0;c<320-10;c+=10)
  99.  {
  100.   RectFill(rp,c,0,c+9,199);        
  101.   SetAPen(rp,MODRED+ ((c+10)/10%16) );
  102.   RectFill(rp,320+c,0,c+329,199);        
  103.   SetAPen(rp,MODGRN+ ((c+10)/10%16) );
  104.   RectFill(rp,640+c,0,c+649,199);        
  105.  }
  106.  
  107. } /* end of Ham() */
  108.  
  109. scroll()
  110. {
  111.  int i;
  112.  
  113.  for(i=1;i<=WIDTH-320;i++)
  114.  {
  115.   Scrn->ViewPort.RasInfo->RxOffset=i;
  116.   MakeScreen(Scrn);
  117.   RethinkDisplay();
  118.  }
  119.  
  120.  for(i=WIDTH-320;i;i--)
  121.  {
  122.   Scrn->ViewPort.RasInfo->RxOffset=i-1;
  123.   MakeScreen(Scrn);
  124.   RethinkDisplay();
  125.  }
  126. }
  127.  
  128.  
  129.         
  130.